package operations;

import javax.swing.JTextArea;
import javax.swing.text.BadLocationException;

public class FindNextStragtegy extends BaseClass implements FindInterface{
	
	protected static int StartIndex;
	protected static int EndIndex;
	
	public void FindPattern(JTextArea text, String SearchedWord) {		
		RemoveHighlights(text);
		DefinePattern(text,SearchedWord);
		DefineHighlighter(text);
		if(!SearcheWordSteream.find()){
				// There is no match pattern
		}
		if(SearcheWordSteream.find(EndIndex)){
			text.setSelectionStart(SearcheWordSteream.start());
		    text.setSelectionEnd(SearcheWordSteream.end());
		    text.requestFocusInWindow();
		    EndIndex = SearcheWordSteream.end();
		    StartIndex=EndIndex-SearchedWord.length();
		    try {
		    	highlighter.addHighlight(SearcheWordSteream.start(), SearcheWordSteream.end(),PainterNext );
		    	} catch (BadLocationException e) {
					e.printStackTrace();
				}
		        }
		    else{
		    	EndIndex=0;
		    }
	}
}
